Fix KeyNotFoundException / ArgumentException on drawing rename and removal#2379
Merged
swmal merged 1 commit intoJun 18, 2026
Merged
Conversation
Contributor
|
Hello @lievendf, and thank you for this PR! I've had a look and it does indeed address a bug in the internal handling of drawing names. Since this is a non-trivial fix, we'll need you to sign our CAA before we can proceed. Please see the Contributing.md file in the repo for details on the process.. The CAA form can be downloaded as a PDF here. The signed form should be emailed to github at epplussoftware dot com. Once that's in place we'll do a full review and follow up with any feedback. |
…andard/grouped drawings
59d42c0 to
571d061
Compare
JanKallman
added a commit
that referenced
this pull request
Jun 30, 2026
* Feature/pivotbyv2 (#2365) * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * Fixed failing test * New pivotby branch * Added some failing unit tests * WIP * WIP * WIP * WIP --------- Co-authored-by: swmal <897655+swmal@users.noreply.github.com> * #2311 - Implemented new Excel functions (#2364) * #2311 - Implemented WRAPROWS and WRAPCOLS * #2311 - Implemented USDOLLAR * #2311 - Implemented CODE and ENCODEURL functions * #2311 - Added Array support for DOLLAR, USDOLLAR, CODEAND ENCODEUR * #2311 - Added EPPlus version to FunctionMetadata * EPPlus version 8.6.0 * Fix: ExcelWorksheets.Delete throws NotSupportedException on ExcelChartsheet (#2367) The Delete method was attempting to access the PivotTables collection on all worksheet types. However, ExcelChartsheet throws NotSupportedException when accessing PivotTables. Added a type guard to skip PivotTable cleanup for chart sheets. Co-authored-by: Lieven De Foor <lieven.de.foor@tvh.com> * Fixes issue #2372 * Updated test * Fixed test that affected static values of the Chart Style Manager, causing a later test to fail * Fix case-sensitivity enum parsing bug in ExcelChartAxisStandard MajorTickMark and MinorTickMark (#2370) Co-authored-by: Lieven De Foor <lieven.de.foor@tvh.com> * Fixed some trendline issues * Fixes issue #2376 * Removed, renamed and fixed a few issues * Added new ActualPosition property for axis * Re-implemented pie-chart and explosion * Fixed trendline formulas to add superscript to textboxs * Added debug properties to pie slices * Deactivated debug props + cleanup * Simplified constructor * Fixed most trendline sub/superscript issues + rect * Added margins to rect * Half fix for duplication * Fixed datalabel positions. Messily. * Fixed datalabels more. Started fixing centering trendline * Fixed DrawingTextBox duplicate properties * Fixed Most of trendline centering * Added spacing in trendline strings * Fixed stacking axis * Tweaked tests. Added recalculation to textbody * Fixed positioning of stacked axis * WIP:Axis positioning and sizeing * Fixed line-ending issue * Verified vertical alignment also functional * Changed TextBox. GroupItem realtime. + margin grp * Added tests for new textbox * Fixed alignment bug and in ChartTitle.DisplayedText * Partial trendline fix * Partial fix for trendline autosize alignment issue * Functional Trendlines fix * #2383 - Fixed issue where VLOOKUP and HLOOKUP sometimes returned wrong value on unsorted data. (#2384) * #2383 - Fixed issue where VLOOKUP and HLOOKUP sometimes returned wrong value on unsorted data * #2483 - Fix approximate VLOOKUP/HLOOKUP to match Excel * Fixed center-alignment for shapes * Fixed sIcon location on datalabel * Fixes axis position * Fixed width of textbox * Added fix for html images * Feature/regexfunctions (#2373) * WIP * WIP * WIP * WIP * WIP * Fix REGEXEXTRACT/REGEXREPLACE scalar bugs: invalid return_mode validation, no-match now returns #N/A, empty pattern inserts replacement. Split regex tests into one file per function, verified against Excel desktop. * Refactored unit tests --------- Co-authored-by: swmal <897655+swmal@users.noreply.github.com> Co-authored-by: swmal <{ID}+username}@users.noreply.github.com> * Fixed multiple paragraph test * Temporary fix for exact font * Bugi2381 - ConditionalFormatting DxfStyleId miss-match (#2386) * Potential solution/verification ids off by 1 * Implemented better solution that does not break tests * Cleanup * Additional cleanup * WIP:Added first test for errorbars * Fixed infinite loop in GetTolColumnFromPixels. (#2382) * Fixed infinite loop in GetTolColumnFromPixels. Also fixed a crash when saving workbook with groupshape as a shape in a chart. * Fixed positioning of shapes in charts * get top and left no longer returns 0. * fixed From To calculation for chart drawings. * fixed absolute positioning --------- Co-authored-by: Jan Källman <jan.kallman@epplussoftware.com> * Fixed issue where rotated text would partially hide border (#2380) * Fixed issue where rotated text would partially hide border * Fixed several bugs in the HTML export. Row height was not set using invariant culture. Pattern fill was incorrect when the color was blank. Border style was not correct for Right and Bottom borders on merged cells * Solved rotated column headers + savefile location --------- Co-authored-by: Jan Källman <jan.kallman@epplussoftware.com> Co-authored-by: Ossian Edström <ossian.edstrom@epplussoftware.com> * Fixed some issues on chart axis and legends. * Partial fix for datalabels * EPPlus version 8.6.1 * Fixed background for datalabels * Removed some warnings, mostly due to usage of ExpectedException in UnitTests * Replaced DataTestMethod->TestMethod in unit tests * Fixed small error in positioning of shapes in charts * Transferred piechart legend special case * Fixed label position on horizontal axis * Fixes axis label alignment and label positioning * Fixed centering of piechart legend * Start of datalabels for barcharts * Fixed out-end for bar-charts * Functional datalabels * Columnn and bar charts correct * fixed stacked column pos datalabels * Start of better datalabel system+debug * Started Work on error bars * New position functional for center and in-base * Made labels work for inEnd and inBase again * Added outEnd * Simplified initilization in barChart * Made new system functional for bars AND columns * Fix KeyNotFoundException/ArgumentException on renaming or removing standard/grouped drawings (#2379) Co-authored-by: Lieven De Foor <lieven.de.foor@tvh.com> * Fix IndexOutOfRangeException in LoadFromText with trailing columns (#2388) Co-authored-by: Lieven De Foor <lieven.de.foor@tvh.com> * Fix url of license information in Readme.md (#2389) * Ensured mix of series and custom datalabels get read * Fix: drawing hyperlink reassignment crashes and inert tooltip setting (#2378) Co-authored-by: Lieven De Foor <lieven.de.foor@tvh.com> * Added support for negative columns + margin * Ensured works for bar charts as well * Added simpler but somewhat unclear method * Attempting to use functionality in pie item * Fixed several pie chart datalabel bugs * Fixed bugs and cleaned up datalabels * Cleanup and added all pie datalabels to same file * Start of adding svg to html export * Render of Errorbars for line charts * Added html tests * Fixed Errorbars issue * Added category test * Fixed gapwidth for barcharts * Strong named EPPlus.DrawingRenderer and added tests for .NET 4.6.2. * Added stylemanager styling * Fixed ellipse items having rect type * Fixed trendline label positioning * Fixed trendline label positioning. * Fixed databar bug + styling border issue * Fixed null color for shapes and charts * Fixed blip fills * Start of fix for title element * Fixed title bug in epplus * Fixes errorbars for bar charts * Fixed one test-failure * Fixed Line Markers * Fixed failing tests for Archivo Narrow * Fixed corrupting issues with previous fix * Turned off debug points for dlbl * Fixed axis and trendlines issues * Differing shape and chart fill * Attempt att resolving style hierarchy correctly * Added new option class to the ToSvg method * Adding additional tests * Fix for autofit columns with autofilters (#2390) * Added base-functional chart export * Allow AppVersion in OfficeProperties to be set to null. #2393. (#2394) * Fixed absolute positioning for charts * Start of relative position + multiple charts/shapes * Documented change to DrawingFillBasic --------- Co-authored-by: karlkallman <137038948+karlkallman@users.noreply.github.com> Co-authored-by: swmal <897655+swmal@users.noreply.github.com> Co-authored-by: Lieven De Foor <8639525+lievendf@users.noreply.github.com> Co-authored-by: Lieven De Foor <lieven.de.foor@tvh.com> Co-authored-by: OssianEPPlus <122265629+OssianEPPlus@users.noreply.github.com> Co-authored-by: Ossian Edström <ossian.edstrom@epplussoftware.com> Co-authored-by: swmal <{ID}+username}@users.noreply.github.com> Co-authored-by: AdrianEPPlus <162118292+AdrianEPPlus@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ExcelDrawingupdated the underlying XML but failed to synchronize the change with the parent's_drawingNameslookup dictionary. This caused subsequent lookups andRemove()calls on renamed drawings to fail with aKeyNotFoundException.ExcelDrawingsGroup.Remove()removed drawings from the internal list but did not clean up their entries from the_drawingNamesdictionary or re-index the remaining shapes, causing index desynchronization._drawingNamesdictionary inExcelDrawingsGroupwas case-sensitive, unlike the worksheet-level dictionary which is case-insensitive, resulting in inconsistent behavior.Solution
ExcelDrawing.Namesetter to validate uniqueness across both worksheet and group-level collections first, then update both lookup dictionaries.ExcelDrawingsGroup.Removeto remove the shape's name from_drawingNamesand re-index the shifted indices of the remaining drawings in the group._drawingNamesinExcelDrawingsGroupwithStringComparer.OrdinalIgnoreCaseto align with worksheet-level drawing lookups.Testing
Added unit tests in
DrawingTest.csto verify renaming and removal behavior for both standard and grouped drawings:DrawingNameChangeAndRemovalTestGroupedDrawingNameChangeAndRemovalTest